package com.kaifamiao.N0809;

import java.util.Arrays;

public class Test1 {

    public static String[] sort(String args){
        String[] ss = args.split(",");

        int minPos;
        String temp;

        for (int i = 0; i < ss.length-1; i++) {
            minPos = i;
            for (int j = i+1; j <  ss.length; j++) {
                //把字串转换成整数再进行对比
                int nextNum = Integer.parseInt(ss[j]);
                int curNum = Integer.parseInt(ss[minPos]);
                if(nextNum<curNum)
                    minPos = j;
            }
            if(i!=minPos) {
                temp = ss[minPos];
                ss[minPos] = ss[i];
                ss[i] = temp;
            }
        }
        return ss;
    }

    public static void main(String[] args) {
        String s = "100,10,1,0,15,20";
        System.out.println(Arrays.toString(sort(s)));

    }
}
